package com.zyk.script.manager.main;

import com.zyk.script.manager.ScriptManager;
import com.zyk.script.manager.holder.PropertiesHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Properties;

/**
 * Hello world!
 */
public class ScriptBootstrap {
    private static final Logger logger = LoggerFactory.getLogger(ScriptBootstrap.class);

    public static void main(String[] args) throws IOException {
        Properties properties = loadClassPathProperties();
        ScriptManager scriptManager = new ScriptManager(ScriptBootstrap.class.getClassLoader(), properties);
        scriptManager.run(args);
        logger.info("程序执行完毕");
    }

    private static Properties loadClassPathProperties() {
        PropertiesHolder propertiesHolder = new PropertiesHolder(ScriptBootstrap.class.getClassLoader());
        try {
            return propertiesHolder.loadProperties("script.properties");
        }catch (Exception ex){
            logger.warn("[ERROR] bootstrap load error from file -> script.properties, meg:" + ex.toString());
        }
        return null;
    }
}
